<?php
/**
 * Created by PhpStorm.
 * User: woody
 * Date: 17-2-16
 * Time: 下午10:46
 */

namespace App\Http\Controllers\Api;
use App\Models\Messageuserapi;
use Illuminate\Http\Request;

class MessageuserController extends ApiController {

    public function __construct()
    {
        parent::__construct();
        $this->_response['_active']['_model']       = 'messageuser';
        $this->_response['_active']['_action']      = '';
        $this->_response['_title']                  = '小一农货-留言板提交接口';
    }

    /**
     * Created by PhpStorm.
     * User: 房型数据提交
     * Date: 17-2-16
     * Time: 下午10:46
     */
    public function doAdd(\App\Http\Requests\Messageuser $request){
        $data = $request->all();
        global $g_uid;
        $id=$g_uid;
        $saveData = [
            'user_id'=>$id,
            'address' => $data['address'],
            'room'=>$data['room'],
            'area' => $data['area'],
            'phone' => $data['phone'],
            'created_at' => date('Y-m-d H:i:s', time()),
        ];

        $messageuserModel = new Messageuserapi();
        if($messageuserModel->saveData($saveData)){
            return response()->json(['code' => 0, 'msg' => '添加成功']);
        }else{
            return response()->json(['code' => -1, 'msg' => '添加失败']);
        }
    }



}